import cv2
import numpy as np

# FilePath = "/home/jpz/Desktop/energy-collection---camera-master/demo2/"

# image = cv2.imread(FilePath + "a.jpg")   #加载图片
# (h, w, d) = image.shape
# print("width={}, height={}, depth={}".format(w, h, d))
# cv2.imshow("Image", image)
# cv2.waitKey()

# 视频获取
cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()

    cv2.imshow("frame", frame)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.imshow("gray", gray)

    if cv2.waitKey(1) & 0xff == ord(' '):
        break;

cap.release()
cv2.destroyAllWindows()
